//
//  MyDetailViewController.m
//  Qihuo
//
//  Created by Vencoo on 13-11-12.
//  Copyright (c) 2013年 Vencoo. All rights reserved.
//

#import "MyDetailViewController.h"
#import "NewsViewController.h"
@interface MyDetailViewController ()
{
    ASIFormDataRequest *queryNews;
}
@end

@implementation MyDetailViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    self.title = @"详细信息";
    
    NSURL *queryUrl = [NSURL URLWithString:detailNew_IP];
    ASIFormDataRequest *queryRequest = [[ASIFormDataRequest alloc] initWithURL:queryUrl];
    [queryRequest setPostValue:self.delegate.ID forKey:@"newsId"];
    [queryRequest startSynchronous];
    NSString *response = [queryRequest responseString];
    NSDictionary *queryDic = [response JSONValue];
    NSDictionary *queryDataDic = [queryDic objectForKey:@"data"];
    NSLog(@"%@",queryDataDic);

    
    UILabel *newsTitle = [UILabel new];
    newsTitle.text = [queryDataDic valueForKey:@"title"];
    newsTitle.font = [UIFont systemFontOfSize:35];
    newsTitle.backgroundColor = [UIColor clearColor];
    newsTitle.textColor = [UIColor whiteColor];
    CGSize fontSize = [newsTitle.text sizeWithFont:newsTitle.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    if (_iOS7) {
        newsTitle.frame = CGRectMake((scrennWidth - fontSize.width)/2, 84, fontSize.width, fontSize.height);
    }else{
        newsTitle.frame = CGRectMake((scrennWidth - fontSize.width)/2, 64, fontSize.width, fontSize.height);
    }

    
    [self.view addSubview:newsTitle];
    
    UIImage *whiteimage = [UIImage imageNamed:@"底框-白.png"];
    UIImageView *MyView = [[UIImageView alloc]initWithFrame:CGRectMake((scrennWidth - whiteimage.size.width)/2, newsTitle.frame.origin.y + 86, whiteimage.size.width, whiteimage.size.height)];
    MyView.image = whiteimage;
    [MyView setUserInteractionEnabled:YES];
    [self.view addSubview:MyView];
    
    UILabel *dateLb = [UILabel new];
    dateLb.text = [queryDataDic valueForKey:@"crttime"];
    dateLb.font = [UIFont systemFontOfSize:24];
    dateLb.backgroundColor = [UIColor clearColor];
    dateLb.textColor = [UIColor whiteColor];
    fontSize = [dateLb.text sizeWithFont:dateLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    dateLb.frame = CGRectMake(1004 - fontSize.width, newsTitle.frame.origin.y + newsTitle.frame.size.height + 10, fontSize.width, fontSize.height);
    [self.view addSubview:dateLb];
    
    UILabel *personLb = [UILabel new];
    personLb.text = [queryDataDic valueForKey:@"crtuser"];
    personLb.font = [UIFont systemFontOfSize:24];
    personLb.backgroundColor = [UIColor clearColor];
    personLb.textColor = [UIColor whiteColor];
    fontSize = [personLb.text sizeWithFont:personLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    personLb.frame = CGRectMake(1004 - fontSize.width - dateLb.frame.size.width - interval111, newsTitle.frame.origin.y + newsTitle.frame.size.height + 10, fontSize.width, fontSize.height);
    [self.view addSubview:personLb];
    
    UITextView *contentView = [[UITextView alloc]initWithFrame:CGRectMake(interval111, interval111, whiteimage.size.width - interval111*2, whiteimage.size.height - interval111 *2)];
    contentView.text = [queryDataDic valueForKey:@"content"];
    contentView.textColor = [UIColor blackColor];
    contentView.backgroundColor = [UIColor clearColor];
    contentView.font = [UIFont systemFontOfSize:24];
    contentView.editable = NO;
    [MyView addSubview:contentView];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
